import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:study_demo/base/BaseController.dart';

class TransformLowerToUpperController extends BaseController {
  TextEditingController _textEditingController = TextEditingController();

  TextEditingController get textEditingController => _textEditingController;

  TextEditingController _resultTextEditingController = TextEditingController();

  TextEditingController get codeTextEditingController =>
      _resultTextEditingController;

  transform({int type = 0}) {
    _resultTextEditingController.text = type == 0
        ? textEditingController.text.toUpperCase()
        : textEditingController.text.toLowerCase();
  }

  copyCode() {
    copyToClipboard(_resultTextEditingController.text);
  }

  Future<void> copyToClipboard(String text) async {
    await Clipboard.setData(ClipboardData(text: text)); // 设置剪贴板数据
  }
}
